<?php

class Object_Blog extends Object_Abstract {
	
	const BLOG_PRIVATE = 0;
	const BLOG_PUBLIC = 1;
	const BLOG_STARRED = 2;
	
	const BLOG_REMARK_OPEN = 1;
	const BLOG_REMARK_BAN = 0;
	
	public function isPublic() {
		return $this->isEqual ( 'level',  self::BLOG_PUBLIC);
	}
	public function isPrivate() {
		return $this->isEqual ( 'level',  self::BLOG_PRIVATE);
	}	
	public function isStarred(){
		return $this->isEqual ( 'level',  self::BLOG_STARRED);
	}
	public function isOpenRemark(){
		return $this->isEqual ( 'can_remark',  self::BLOG_REMARK_OPEN);
	}
	public function isBanRemark(){
		return $this->isEqual ( 'can_remark',  self::BLOG_REMARK_BAN);
	}
	
	public function getTextColor(){
		if($this->isStarred()){
			return "FF9900";
		}elseif($this->isPublic()){
			return "66CC00";
		}else{
			return "999999";
		}	
	}
	
	private $_tags = null;	
	/**
	 * @return Object_Blog
	 */
	public function setTagInfo($tags = null){
		if(!empty($tags)){
			$this->_tags = $tags;
		}else{
			$tt = Module_Impl_Relation_Select::getInstance();
			$options[Module_Impl_Relation_Select::SQLARRAY_OPTION_JOIN_TAG] = true;
			$results = $tt->getByField('blog_id',$this->id,$options,false);
			$this->_remarks = $results;
		}
		return $this;
	}
	public function getTagInfo(){
		return $this->_tags;
	}	
	private $_remarks = null;	
	/**
	 * @return Object_Blog
	 */
	public function setRemarkInfo($remarks = null){		
		if(!empty($remarks)){
			$this->_remarks = $remarks;
		}else{
			$tt = Module_Impl_Remark_Select::getInstance();
			$results = $tt->getByField('blog_id',$this->id,array(),false);
			$this->_remarks = $results;
		}
		return $this;
	}
	public function getRemarkInfo(){
		return $this->_remarks;
	}	
}